
exports.findAllSQL = (table, ...rest) => {
  let sql = `SELECT * FROM ${table} WHERE`;
  const { length } = rest;
  for (let i = 0; i < length; i++) {
    sql += ` ${rest[i]} = ? ${i !== length - 1 ? 'AND' : ''}`;
  }
  return sql
};

exports.executeDb = (db, sql, value = [],) =>
  new Promise((resolve, reject) => {
    db.execute(sql, value, (err, result, fields) => {
      if (err) reject(err)
      else resolve(result, fields)
    })
  });